package com.todo.content.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.content.application.backend.service.ContentTopicBackendService;
import com.todo.content.iface.backend.ContentTopicBackendIface;
import com.todo.content.iface.backend.request.*;
import com.todo.content.iface.backend.response.ContentTopicDetailByIdResp;
import com.todo.content.iface.backend.response.QueryContentTopicByConditionResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/7/5 11:43
 * @description
 */
@RestController
@RequestMapping("/bd/content/topic")
@Tag(name = "内容话题后台处理类", description = "内容话题后台处理类")
public class ContentTopicBackendController implements ContentTopicBackendIface {

    @Resource
    private ContentTopicBackendService contentTopicBackendService;


    @Override
    @Operation(summary = "新增话题信息")
    @PostMapping("/insertContentTopic")
    public BizResponse<Boolean> insertContentTopic(@RequestBody InsertContentTopicReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentTopicBackendService.insertContentTopic(req);
    }

    @Override
    @Operation(summary = "根据主键id更新话题信息")
    @PostMapping("/updateContentTopicById")
    public BizResponse<Boolean> updateContentTopicById(@RequestBody UpdateContentTopicByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentTopicBackendService.updateContentTopicById(req);
    }

    @Override
    @Operation(summary = "根据主键删除话题信息")
    @PostMapping("/removeContentTopicById")
    public BizResponse<Boolean> removeContentTopicById(@RequestBody RemoveContentTopicByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentTopicBackendService.removeContentTopicById(req);
    }

    @Override
    @Operation(summary = "启禁用话题信息")
    @PostMapping("/enableContentTopicById")
    public BizResponse<Boolean> enableContentTopicById(@RequestBody EnableContentTopicByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentTopicBackendService.enableContentTopicById(req);
    }

    @Override
    @Operation(summary = "根据主键信息查询话题详情")
    @PostMapping("/queryContentTopicById")
    public BizResponse<ContentTopicDetailByIdResp> queryContentTopicById(@RequestBody QueryContentTopicByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentTopicBackendService.queryContentTopicById(req);
    }

    @Override
    @Operation(summary = "多条件查询话题信息")
    @PostMapping("/queryContentTopicByCondition")
    public BizPageResponse<QueryContentTopicByConditionResp> queryContentTopicByCondition(@RequestBody QueryContentTopicByConditionReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return contentTopicBackendService.queryContentTopicByCondition(req);
    }
}
